<?php
//if(isset($_POST['newuser'])){
	//echo "newuser entered";
	$_SESSION['newuser'] = 1;
	if($_GET['newuser'] == 0){
	$user = new utilisateur();
		if(!$user->tryUserExist($_POST['username'])){
			$user->setLogin($_POST['username']);
			$user->setPwd($_POST['password']);
			if(isset($_POST['nom']))
			$user->setNom($_POST['nom']);
			if(isset($_POST['prenom']))
			$user->setPrenom($_POST['prenom']);
			if(isset($_POST['email']))
			$user->setEmail($_POST['email']);
			if(isset($_POST['tel']))
			$user->setTel($_POST['tel']);
			if(isset($_POST['telEts']))
			$user->setTelEntreprise($_POST['telEts']);
			if(isset($_POST['ets']))
			$user->setEntreprise($_POST['ets']);
			if(isset($_POST['newsletter'])){
				foreach($_POST['newsletter'] as $news){
					$user->setNewsLetter($news);
				}
			}
			
			$user->addUser();
			
			$_SESSION['user'] = serialize($user);
			$url = 'index.php';
			unset($_SESSION['newuser']);
			header("Refresh: 0, url=$url");	
		}
		else {
			echo "user exists";
		}
		}

//}
?>
